/*******************************************************************************
 *                                                                             *
 * Square3D Engine                                                             *
 * (C) 2010 Aviral Dasgupta <aviraldg@gmail.com>                               *
 *                                                                             *
 *******************************************************************************
 * SDLCore.cpp                                                                 *
 ******************************************************************************/

#include <cstdio>
#include <cstdlib>
#include <SDL/sdl.h>

#include "Square/Engine.h"

int main(int argc, char *argv[])
{
	if(SDL_Init(SDL_INIT_EVERYTHING)==0)
		atexit(SDL_Quit);
	else
	{
		fprintf(stderr, "%s", "Error <Square3D::SDLCore>: SDL_Init failed!\n");
		return EXIT_FAILURE;
	}
	
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	SDL_Surface *screen;
	if((screen = SDL_SetVideoMode(800, 600, 32, SDL_OPENGL) == NULL)
	{
		fprintf(stderr, "%s",
				"Error <Square3D::SDLCore>: Failed to set video mode.\n");
		return EXIT_FAILURE;
	}
	
	Engine engine;
	engine.run();
	
	return engine.finish();
}

